<?php

App::uses("ValuesBuildAbstract", "Wchart.Lib/chart");

class ValuesBuildWebservices extends ValuesBuildAbstract {

	function build() {
		// richiamo un server REST mi aspetto dei dati
		// CakeLog::debug("prima il redirect");

		$url = $this->serie["datasource"];
		$handle = curl_init($url);
		curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);
		/* Get the HTML or whatever is linked in $url. */
		$response = curl_exec($handle);
		/* Check for 404 (file not found). */
		$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
		if ($httpCode == 200)
			$this->data = json_decode($response);
		curl_close($handle);
		// CakeLog::debug("data: ".json_encode($this->data));
		// CakeLog::debug("dopo il redirect");
		// echo $data;die;
	}
	
	// function curl($url){
	    // $ch = curl_init();
	    // curl_setopt($ch, CURLOPT_URL, $url);
	    // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	    // $data = curl_exec($ch);
	    // curl_close($ch);
	    // return $data;
	// }
	
	
}
?>